import { EventType } from "../settings/const";

export class Events {
    /**事件句柄 */
    eHandle: number;

    eNote: string;
    /**事件参数 */
    eParam: string
    /**结束时间戳 */
    eStartTime: number
    /**当前时间戳 */
    eTime: number
    /**事件类型 */
    eType: number
    eUid: number
    eZone: number
    eusername: string

   

    static createByObj(obj:any):Events{
        let e = new Events()
        for(let key in obj){
            e[key] = obj[key]
        }
        return e

    }

    get title():string{

        
        if (this.eType == EventType.advBuild){
            return '建造中'
        }

        if (this.eType == EventType.destroy){
            return '拆除中'
        }

        return ''
    }


    /**
      * 根据服务端的数据,创建当前正在进行中的探险的数据
      * @param arr 
      * @returns 
      */
    static getEsList(arr): Events[] {
        let list: Events[] = []
        let event = Events.createByObj(arr[0])
       
        list.push(event)

        return list
    }

    get treaName ():string{
        if (this.eParam + '' == 1 + '') {
            return '初级探险中'
        } else if (this.eParam + '' == 2 + '') {
            return '中级探险中'
        } else if (this.eParam + '' == 3 + "") {
            return '高级探险中'
        }

        return ''

    }

}


